<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('user_name')->unique()->comment('用户名');
            $table->string('password')->comment('密码（哈希存储）');
            $table->string('email')->unique()->comment('邮箱');
            $table->string('role')->default('user')->comment('角色');
            $table->string('phone')->nullable()->unique()->comment('手机号');
            $table->boolean('is_disabled')->default(false)->comment('是否禁用：0=未禁用，1=已禁用');
            $table->unsignedBigInteger('avatar_id')->nullable()->comment('头像ID（关联头像表）');
            $table->timestamps();
            $table->softDeletes()->comment('删除时间（软删除）');
        });
    }

    public function down()
    {
        Schema::dropIfExists('users');
    }
}
